""" GUI 界面 """

import tkinter as tk

from tkinter import *

from tkinter import messagebox


class Gui(tk.Frame):
    """ init func"""

    def __init__(self, master=None):
        tk.Frame.__init__(self, master)
        self.master.title('App')
        self.master.resizable(False, False)
        left_frame = tk.Frame(self.master)
        right_frame = tk.Frame(self.master)
        # Label(left_frame, text="中国", bg="green", font=("Arial", 12), width=10, height=2).pack(side=TOP)
        # Label(left_frame, text="日本", bg="green", font=("Arial", 12), width=10, height=2).pack(side=TOP)

        self.game_area = Canvas(left_frame, width=600, height=600, bg='white')
        self.game_area.pack()
        self.draw_grid(20)
        self.score_area = Canvas(right_frame, width=200, height=600, bg='white')
        Label(self.score_area, text="得分栏", bg="grey", font=("Arial", 12), width=10, height=2).pack(side=TOP)
        self.create_menu()
        # Label(self.score_area, text="ShangHai", bg="green", font=("Arial", 12), width=10, height=2).pack(side=BOTTOM)
        self.score_area.pack()
        left_frame.pack(side=LEFT)
        right_frame.pack(side=RIGHT)
        self.pack()

    """ create menu """

    def create_menu(self):
        menu_bar = tk.Menu(self.master)
        menu = Menu(self.master)

        menu_bar.add_cascade(label='操作', menu=menu)
        self.master.config(menu=menu_bar)

    """ exit """

    def quit(self):
        q = tk.messagebox.askokcancel('提示', '真的要走吗？')
        if q is True:
            self.master.destroy()

    """ paint game area """

    def draw_grid(self, line_distance):
        self.game_area.create_rectangle(0, 0, 600, 600, outline='black')
        for x in range(0, 600, line_distance):
            self.game_area.create_line(x, 0, x, 600, fill='#d3d3d3')

        for y in range(0, 600, line_distance):
            self.game_area.create_line(0, y, 600, y, fill='#d3d3d3')

    """ show frame center location"""

    def location_center(self):
        width = self.winfo_screenwidth()
        height = self.winfo_screenheight()
        x = width / 2
        y = height / 2
        self.master.geometry('%d+%d' % (x, y))

    """ create component on frame """

    def create_component(self):
        pass


def main():
    app = Gui()
    app.mainloop()


if __name__ == '__main__':
    main()
